<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    		<% 
String path = request.getContextPath(); 
// 获得项目完全路径（假设你的项目叫MyApp，那么获得到的地址就是 http://localhost:8080/MyApp/）: 
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 
%> 
<!DOCTYPE html>
<html>
<head>
<base href=" <%=basePath%>"> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="后台用户管理">
<meta name="author" content="xwj">
<title>用户管理</title>
<link href="bootstrap/bootstrap.css" rel="stylesheet">

<link href="css/admin_css/assets/font-awesome/css/font-awesome.css"
	rel="stylesheet" />
<link rel="stylesheet" type="text/css"
	href="css/admin_css/assets/css/zabuto_calendar.css">
<link rel="stylesheet" type="text/css"
	href="css/admin_css/assets/js/gritter/css/jquery.gritter.css" />
<link rel="stylesheet" type="text/css"
	href="css/admin_css/assets/lineicons/style.css">

<link href="css/admin_css/assets/css/style.css" rel="stylesheet">
<link href="css/admin_css/assets/css/style-responsive.css"
	rel="stylesheet">
<script src="jquery/jquery-2.2.4.min.js"></script>
<script src="bootstrap/bootstrap.min.js"></script>

<script class="include" type="text/javascript"
	src="css/admin_css/assets/js/jquery.dcjqaccordion.2.7.js"></script>
<script src="css/admin_css/assets/js/jquery.scrollTo.min.js"></script>
<script src="css/admin_css/assets/js/common-scripts.js"></script>

<script src="bootstrap/bootstrap.min.js"></script>
<!-- 表单验证 -->
<script
	src="bootstrap/bootstrapvalidator/js/bootstrapValidator.min.js"></script>
<!-- 分页工具 -->
<script type="text/javascript" src="jsutil/pagetool.js"></script>
<!-- 时间处理工具 -->
<script type="text/javascript" src="jsutil/timeutil.js"></script>
   
    <script type="text/javascript">
	var pageNum = 1;
    $(function() {
    	// $('select.styled').customSelect();
    	getUser(pageNum);
    	
		}
    );
  //分页查询
	function getUser(pageNum) {
		var uname = $("input[name='q_uname']").val();
		var urelname = $("input[name='q_urelname']").val();
		var utel = $("input[name='q_utel']").val();
		$.ajax({
					url : "userMsg/getUserList.do", // 请求地址
					type : "POST", // 请求类型
					async : "true", // 是否异步方式
					data : {
						"num" : pageNum,
						"uname" : uname,
						"urelname":urelname,
						"utel":utel
					},
					dataType : "json", // 返回数据格式
					success : function(data) {
						var tbodys = $("tbody").empty();
						if (data.res == 1) {
							totalPage=data.totalPage;
							$.each(data.list,function(index, element) {
								//时间处理
								var d = new Date(element.uregtime);  
								var regtime=formatDateTime(d);  
								var relname="未设定";
								var qq="未设定";
								var address="未设定";
								var email="未设定";
								if(element.urelname!=null||element.urelname!=undefined){
									relname=element.urelname;
								}
								if(element.uqq!=null||element.uqq!=undefined){
									qq=element.uqq;
								}
								if(element.uaddress!=null||element.uaddress!=undefined){
									address=element.uaddress;
								}
								if(element.uemail!=null||element.uemail!=undefined){
									email=element.uemail;
								}
								var trs="<tr><td>"+(index+1)+"<input type='hidden' value='"+element.uid+"'/>"
								+"<input type='hidden' value='"+element.ustate+"'/>"
								+"</td>"
									+"<td>"+element.uname+"</td>"
									+"<td>"+relname+"</td>" 
									+"<td>"+element.utel+"</td>"
									+"<td class='hidden-phone'>"+qq+"</td>"
									+"<td  class='hidden-phone'>"+address+"</td>"
									+"<td class='hidden-phone'>"+email+"</td>"
									+"<td class='hidden-phone'>"+regtime+"</td>";
								var td_state0="<td><span class='label label-danger label-mini'>禁用</span></td>"
											  +"<td><button class='btn btn-success btn-xs' onclick='del(this)'>"
											  +"<i class='fa fa-check'></i></button></td></tr>";
											  
								var td_state1="<td><span class='label label-success label-mini'>正常</span></td>"
									  +"<td><button class='btn btn-danger btn-xs' onclick='del(this)'>"
									  +"<i class='fa fa-bolt' ></i></button></td></tr>";
									  
									   if(element.ustate==0||element.ustate=="0"){
										  trs=trs+td_state0;
									  }else{
										  trs=trs+td_state1;
									  } 
												tbodys.append(trs);
											});
							setPage(pageNum, data.totalPage, "getUser");
						}

					}
				});
  }
    
  //禁用和解禁用户
  function del(obj){
	  var tds = $(obj).parent().parent().find('td');
		var uid = tds.eq(0).find('input').eq(0).val();
		var uname = tds.eq(1).text();
		var ustate = tds.eq(0).find('input').eq(1).val();
		if(ustate=='0'||ustate==0){
			 if (!confirm("确认要解除用户："+uname+"的禁止吗?")) {
					return;
				}
		}else{
			if (!confirm("确认要禁止用户："+uname+"吗?")) {
				return;
			}
		}
		$.ajax({
			url : 'userMsg/del.do',
			type : 'POST',
			async : "true",
			data : {
				"uid" : uid,
				"ustate":ustate
			},
			dataType : 'json',
			success : function(data) {
				if (data.res > 0) {
					alert("操作成功！");
						getUser(1);
					
				}else{
					alert("操作失败！");
				}
			}
		});
  }
    </script>
 
</head>
<body>
<section id="container" >
     
      <!--header start-->
     <%@include file="header.jsp"%>
      <!--header end-->

      <!--sidebar start-->
        <aside>
          <div id="sidebar"  class="nav-collapse ">
              <!-- sidebar menu start-->
              <ul class="sidebar-menu" id="nav-accordion">
              
              	  <p class="centered"><a href="admin/adminmag.jsp"><img src="images/admin7.png" class="img-circle" width="60"></a></p>
              	  <h5 class="centered">${admin.aname}</h5>
              	  	
                  <li class="mt">
                      <a  href="admin/index.jsp">
                          <i class="fa fa-bar-chart-o"></i>
                          <span>销售统计</span>
                      </a>
                  </li>

                  <li class="sub-menu">
                      <a  href="javascript:;" >
                          <i class="fa fa-book"></i>
                          <span>书籍</span>
                      </a>
                      <ul class="sub">
                          <li ><a  href="admin/bookmag.jsp">书籍管理</a></li>
                          <li ><a  href="admin/categorymag.jsp">类别管理</a></li>
                       
                      </ul>
                  </li>

                  <li class="sub-menu">
                      <a class="active" href="javascript:;" >
                          <i class="fa fa-users"></i>
                          <span>账户</span>
                      </a>
                      <ul class="sub">
                          <li class="active"><a  href="admin/usermag.jsp">用户管理</a></li>
                          <li><a  href="admin/adminmag.jsp">管理员管理</a></li>
                        
                      </ul>
                  </li>
                  <li class="sub-menu">
                      <a href="javascript:;" >
                          <i class="fa fa-user"></i>
                          <span>会员</span>
                      </a>
                      <ul class="sub">
                          <li><a  href="admin/membermag.jsp">会员折扣管理</a></li>
                       
                      </ul>
                  </li>
                  <li class="sub-menu">
                      <a href="javascript:;" >
                          <i class="fa fa-shopping-cart"></i>
                          <span>订单</span>
                      </a>
                      <ul class="sub">
                          <li><a  href="admin/ordermag.jsp">订单管理</a></li>
                      </ul>
                  </li>
                 
              </ul>
              <!-- sidebar menu end-->
          </div>
      </aside>
      <!--sidebar end-->
       <!-- **********************************************************************************************************************************************************
     以上是不变的内容--包括上边header和左边aside33###以下是变化的内容
      *********************************************************************************************************************************************************** -->

      <!--main content start-->
      <section id="main-content">
       <section class="wrapper">
       <h3><i class="fa fa-angle-right"></i> 用户信息管理</h3>
    	 <div class="row mt">
					<div class="col-lg-12">
						<div class="form-panel">
							<h5 class="mb">
								<i class="fa fa-angle-right"></i>操作
							</h5>
							<form class="form-inline" role="form" id="selform">
								<div class="form-group">
									<input type="search" name="q_uname" class="form-control"
										placeholder="请输入用户名">
								</div>
								<div class="form-group">
									<input type="search" name="q_urelname" class="form-control"
										placeholder="请输入用户真实名">
								</div>
								<div class="form-group">
									<input type="search" name="q_utel" class="form-control"
										placeholder="请输入用户电话">
								</div>
								<button type="button" class="btn btn-primary"
									onclick="getUser(1)">查询</button>

							</form>

						</div>
					</div>
				</div>
          <div class="row mt">
                  <div class="col-md-12">
                      <div class="content-panel">
                          <table class="table table-striped table-advance table-hover">
	                  <!-- 	  	  <h4><i class="fa fa-angle-right"></i> 书籍信息管理</h4> -->
	                  	  	  
                              <thead>
                              <tr>
                              	 <th><i class="fa fa-bullhorn"></i> 编号</th>
                                  <th><i class="fa fa-bullhorn"></i> 用户名</th>
                                  <th><i class="fa fa-bullhorn"></i> 真实姓名</th>
                                  <th><i class="fa fa-bullhorn"></i> 电话</th>
                                  <th  class="hidden-phone"><i class="fa fa-bullhorn" ></i> QQ</th>
                                  <th class="hidden-phone"><i class="fa fa-question-circle"></i> 地址</th>
                                  <th  class="hidden-phone"><i class="fa fa-bookmark hidden-phone"></i> 邮箱</th>
                                  <th  class="hidden-phone"><i class="fa fa-bookmark"></i> 注册时间</th>
                                  <th>状态</th>
                                  <th><i class=" fa fa-edit"></i> 操作</th>
                              </tr>
                              </thead>
                              <tbody>
                              </tbody>
                          </table>
                      </div><!-- /content-panel -->
                  </div><!-- /col-md-12 -->
              </div><!-- /row -->
              <div class="" id="mypage">
								<jsp:include flush="fasle" page="/jsutil/pagetool.jsp" />
							</div>
         </section>
      </section><!-- /MAIN CONTENT -->

      <!--main content end-->
     	<!--footer start-->
		<%@include file="footer.jsp"%>
		<!--footer end-->
  </section>

 

</body>
</html>